<template>
	<view class="user-content">
		<view class="custom-navigation">
			<!-- 自定义导航内容 -->
			小春运动
		</view>
		<view class="header-top">
			<view class="header-img">
				<image :src="userInfo.avatar" v-if="userInfo" class="image"></image>
				<image v-else src="../../static/images/user/author_nor.png" class="image"></image>
			</view>

			<view class="header-info">
				<view class="t0"> {{userInfo.nickname||''}}</view>
				<view class="t1">ID：{{userInfo.id||''}}</view>
			</view>
		</view>
		<view class="wallet-box">
			<view class="money">
				<view class="tit">账户余额(元)</view>
				<view class="num">{{ userInfo.money ||'0.00'}}</view>
			</view>
			<view class="money">
				<view class="tit">赠送余额(元)</view>
				<view class="num">{{ userInfo.gifts_money ||'0.00'}}</view>
			</view>
			<view class="charge" @click="goTocharge">
				余额充值
				<image src="../../static/images/user/icon_arrow_white.png" mode="" class="image"></image>
			</view>
		</view>
		<view class="block-list">
			<view class="tit">我的服务</view>
			<view class="list-item" @click="gotoService(1)">
				<view class="item-left">
					<image src="../../static/images/user/icon_setting.png" mode="" class="image"></image>
					<text class="text">我的订单</text>
				</view>
				<view class="item-right">
					<image src="../../static/images/user/icon_right_hui.png" mode="" class="image"></image>
				</view>
			</view>
			<!-- <view class="list-item" @click="gotoService(2)">
				<view class="item-left">
					<image src="../../static/images/user/icon_eye.png" mode="" class="image"></image>
					<text class="text">优惠券</text>
				</view>
				<view class="item-right">
					<image src="../../static/images/user/icon_right_hui.png" mode="" class="image"></image>
				</view>
			</view> -->
			<view class="list-item" @click="gotoService(3)">
				<view class="item-left">
					<image src="../../static/images/user/icon_tel.png" mode="" class="image"></image>
					<text class="text">客服电话</text>
				</view>
				<view class="item-right">
					<text class="text">{{phone}}</text>
					<image src="../../static/images/user/icon_right_hui.png" mode="" class="image"></image>
				</view>
			</view>
		</view>
		<view class="free-active" @click="gotoService(4)">
			<view class="left">我的免单券</view>
			<view class="right">
				<view>查看免单券</view>
				<image src="../../static/images/user/icon_right_hui.png" mode="" class="image"></image>
			</view>
		</view>
		<view class="kefu-img" @click="callPhone"><text class="text">联系客服</text></view>
	</view>
</template>

<script>
	import api from '@/api/index.js';
	export default {
		data() {
			return {
				title: 'Hello',
				phone: '',
				userInfo: null
			};
		},
		onShow() {
			this.getUserInfo();
			this.clickTel()
		},
		methods: {
			getUserInfo() {
				api.getUserInfo().then(res => {
					this.userInfo = res.data.userinfo
					this.$store.commit('saveUserInfo', res.data.userinfo);
				});
			},
			clickTel() {
				api.sysConfig({
					site: 'sys_kefu'
				}).then(res => {
					this.phone = res.data
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.phone
				})
			},
			gotoService(type) {
				if (type === 1) {
					uni.navigateTo({
						url: '/pages/user/orderList' // 跳转到对应路径的页面
					});
				}
				if (type === 2) {}
				if (type === 3) {
					this.callPhone();
				}
				if (type === 4) {
					uni.navigateTo({
						url: '/pages/user/myFreeCoupon' // 跳转到对应路径的页面
					});
				}
			},
			goTocharge() {
				uni.navigateTo({
					url: '/pages/user/recharge' // 跳转到对应路径的页面
				});
			}
		}
	};
</script>

<style lang="scss">
	.user-content {
		background: url('https://oss.bigchun.com/img/home/header-bg.png') no-repeat;
		background-size: 100% 468rpx;
		padding: 88rpx 30rpx 100rpx;

		padding-bottom: 100rpx;

		.custom-navigation {
			text-align: center;
			line-height: 88rpx;
			text-align: center;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 34rpx;
			color: #ffffff;
			font-style: normal;
		}

		.header-top {
			display: flex;
			align-items: center;

			.header-img {
				width: 120rpx;
				height: 120rpx;
				overflow: hidden;
				border-radius: 50%;
				margin-right: 20rpx;

				.image {
					width: 120rpx;
					height: 120rpx;
				}
			}

			.header-info {
				.t0 {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 36rpx;
					color: #ffffff;
					line-height: 50rpx;
					text-align: left;
					font-style: normal;
					margin-bottom: 16rpx;
				}

				.t1 {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #ffffff;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}
			}
		}

		.wallet-box {
			background: url('https://oss.bigchun.com/img/user/block_bg.png') no-repeat;
			background-size: 100% 100%;
			padding: 50rpx 40rpx 0rpx 50rpx;
			height: 200rpx;
			display: flex;

			.money {
				flex: 1;

				.tit {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #000000;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}

				.num {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 60rpx;
					color: #49a1fd;
					line-height: 96rpx;
					text-align: left;
					font-style: normal;
				}
			}

			.charge {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 160rpx;
				height: 48rpx;
				background: #49a1fd;
				border-radius: 24rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #ffffff;
				line-height: 40rpx;
				text-align: center;
				font-style: normal;

				.image {
					width: 14rpx;
					height: 24rpx;
					margin-left: 12rpx;
				}
			}
		}
		.free-active{
			background: #ffffff;
			border-radius: 28rpx;
			padding: 20rpx;
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.left {
				font-weight: 500;
				font-size: 32rpx;
				color: #000000;
				line-height: 50rpx;
				text-align: left;
				font-style: normal;
				position: relative;
				padding-left: 20rpx;
			
				&::before {
					position: absolute;
					content: '';
					width: 10rpx;
					height: 30rpx;
					background: #49a1fd;
					border-radius: 6rpx;
					left: 0;
					top: 12rpx;
				}
			}
			.right{
				display: flex;
				align-items: center;
				justify-content: space-between;
				color: #999999;
				font-size: 24rpx;
				.image {
					width: 20rpx;
					height: 20rpx;
				}
				
			}
		}

		.block-list {
			background: #ffffff;
			border-radius: 28rpx;
			padding: 20rpx;

			.tit {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #000000;
				line-height: 50rpx;
				text-align: left;
				font-style: normal;
				position: relative;
				padding-left: 20rpx;

				&::before {
					position: absolute;
					content: '';
					width: 10rpx;
					height: 30rpx;
					background: #49a1fd;
					border-radius: 6rpx;
					left: 0;
					top: 12rpx;
				}
			}

			.list-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				line-height: 96rpx;
				border-bottom: 2rpx solid #e6e5e5;

				.item-left {
					display: flex;
					align-items: center;

					.image {
						width: 48rpx;
						height: 48rpx;
						background: linear-gradient(180deg, #ffe26f 0%, #ff962d 100%);
						border-radius: 12rpx;
					}

					.text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #222222;
						line-height: 44rpx;
						text-align: left;
						font-style: normal;
						margin-left: 20rpx;
					}
				}

				.item-right {
					.image {
						width: 20rpx;
						height: 20rpx;
					}

					.text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #49a1fd;
						line-height: 44rpx;
						text-align: center;
						font-style: normal;
					}
				}
			}
		}

		.kefu-img {
			background: url('https://oss.bigchun.com/img/home/kefu-bg.png') no-repeat;
			background-size: 124rpx 124rpx;
			position: fixed;
			bottom: 12%;
			right: 12rpx;
			width: 124rpx;
			height: 124rpx;

			.text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 20rpx;
				color: #49a1fd;
				line-height: 24rpx;
				font-style: normal;
				position: absolute;
				right: 20rpx;
				bottom: 20rpx;
			}
		}
	}
</style>